 package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountApply;
import com.briup.jz.bean.extend.AccountApplyExtend;
import com.briup.jz.service.IAccountApplyService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
 
@Api(description = "账号资费变更申请管理接口")
@Validated
@RestController
@RequestMapping("/apply")

public class AccountApplyController {
    @Autowired
    private IAccountApplyService accountApplyService;


    @ApiOperation("查询所有帐户申请")
    @GetMapping("query")
    public Message query(Double money, String apply_type, String status, Long userId) {
        List<AccountApply> list = accountApplyService.query(money, apply_type, status, userId);
        return MessageUtil.success(list);
    }
    @ApiOperation("级联查询所有帐户申请")
    @GetMapping("queryCascade")
    public Message queryCascade(Double money, String apply_type, String status, Long userId) {
        List<AccountApplyExtend> list = accountApplyService.queryCascade(money, apply_type, status, userId);
        return MessageUtil.success(list);
    }
    //保存货更新客户信息
    @ApiOperation("保存或更新申请信息")
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate( AccountApply apply) {
        accountApplyService.saveOrupdate(apply);
        return MessageUtil.success("更新成功");

    }
    
    @ApiOperation(value = "通过id删除申请信息")
    @GetMapping("deleteById")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
    })
    public Message deleteById(@NotNull Long id){
        accountApplyService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
 
}
